package com.qaml.mes.device.domain.convert;

import com.earth.user.AuthSsoContext;
import com.qaml.mes.device.dao.CheckUpkeepRecordDO;
import com.qaml.mes.device.dao.CheckUpkeepRecordRecheckDO;
import com.qaml.mes.device.dto.eqp.CheckUpkeepRecordDTO;
import com.qaml.mes.device.dto.eqp.CheckUpkeepRecordRecheckRespVO;
import com.qaml.mes.device.enums.CheckUpkeepRecordRecheck;
import com.qaml.mes.device.vo.eqp.CheckUpkeepRecordAppVO;
import com.qaml.mes.device.vo.eqp.CheckUpkeepRecordVO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.Date;
import java.util.List;

/**
 * @ClassName CheckUpkeepRecordConvert
 * @Description 检保单
 * @Author leikai
 * @Date 2024/3/7 0007 15:43
 * @Version 1.0
 */
@Mapper
public interface CheckUpkeepRecordConvert {

    CheckUpkeepRecordConvert INSTANCE = Mappers.getMapper(CheckUpkeepRecordConvert.class);


    CheckUpkeepRecordVO do2VO(CheckUpkeepRecordDO checkUpkeepRecordDO);

    CheckUpkeepRecordDO vo2DO(CheckUpkeepRecordVO checkUpkeepRecordVO);

    List<CheckUpkeepRecordVO> dos2VOS(List<CheckUpkeepRecordDO> records);

    CheckUpkeepRecordAppVO do2AppVO(CheckUpkeepRecordDO checkUpkeepRecordDO);

    List<CheckUpkeepRecordAppVO> do2AppVoList(List<CheckUpkeepRecordDO> records);

    CheckUpkeepRecordDO dto2Do(CheckUpkeepRecordDTO checkUpkeepRecordDTO);

    List<CheckUpkeepRecordRecheckRespVO> doRecheck2DTOList(List<CheckUpkeepRecordRecheckDO> recheckDOS);


    default CheckUpkeepRecordRecheckDO buildRecordRecheck(CheckUpkeepRecordDO checkUpkeepRecordDO, CheckUpkeepRecordRecheck.HandlerType handlerType) {
        CheckUpkeepRecordRecheckDO checkUpkeepRecordRecheckDO = new CheckUpkeepRecordRecheckDO();
        checkUpkeepRecordRecheckDO.setCheckUpkeepRecordId(checkUpkeepRecordDO.getId());
        checkUpkeepRecordRecheckDO.setRecheckUserId(AuthSsoContext.getCurrentUserId());
        checkUpkeepRecordRecheckDO.setRecheckUserName(AuthSsoContext.getSsoLoginUser().getUserName());
        checkUpkeepRecordRecheckDO.setRecheckTime(new Date());
        checkUpkeepRecordRecheckDO.setHandleType(handlerType.getType());
        checkUpkeepRecordRecheckDO.setHandleTypeDesc(handlerType.getDesc());
        return checkUpkeepRecordRecheckDO;
    }

}